package com.briup.day16;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

import static jdk.nashorn.internal.codegen.OptimisticTypesPersistence.load;

/**
 * @author 谭梦寻
 * @version 1.1
 */
public class TestProperties {
    public static void main(String[] args) throws IOException {
//        1 创建一个配置类对象
        Properties prop = new Properties();
//        2 通过读取配置文件 添加多个配置信息
        prop.load(new FileReader("db.properties"));
//        3 读取指定的配置信息 解析key-value并输出
        String driver = prop.getProperty("driver");
        String url = prop.getProperty("url");
        String username = prop.getProperty("username");
        String password = prop.getProperty("password");
        System.out.println("driver: " + driver);
        System.out.println("url: " + url);
        System.out.println("username: " + username);
        System.out.println("password: " + password);
    }
}
